package liuch.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class UnsafeI__ {
    public static void main(String[] args) {
//        MyThread thread = new MyThread();
        MyThreadWithAtomic thread = new MyThreadWithAtomic();
        new Thread(thread).start();
        new Thread(thread).start();
        new Thread(thread).start();
        new Thread(thread).start();
        new Thread(thread).start();
    }
}
/**
 * @author 17101651
 * @ClassName UnsafeI__
 * @Description 
 * @data 2018年09月05日
 */  
class MyThread extends Thread {
    int count = 5;

    @Override
    public void run() {
        count--;
        System.out.println(count);
    }
}
class MyThreadWithAtomic extends Thread{
    AtomicInteger atomicInteger = new AtomicInteger(5);

    @Override
    public void run() {
        int a = atomicInteger.decrementAndGet();
        System.out.println(a);
    }
}